Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PHP 8.2 error "Passing null to parameter is deprecated" #4528

Closed
wants to merge 1 commit into from

Conversation

lubosdz
Copy link
Contributor

@lubosdz lubosdz commented Aug 8, 2023

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Tests pass? ✔️

Output buffer(s) may also be empty (containing NULL), which throws an error in PHP 8.2+.

@what-the-diff
Copy link

what-the-diff bot commented Aug 8, 2023

PR Summary

  • Enhancement in HTML Page Rendering Process
    This update primarily refines the way we draw together elements to create the 'head' and 'body' of our website pages. It involves tweaking our coding instructions - specifically by adding '(string)$output' to the 'preg_replace' routines. These are the pieces of code that control how different parts of the page are combined and displayed to the user. This change brings improved efficiency in the page rendering process.

@rob006
Copy link
Contributor

rob006 commented Aug 8, 2023

Output buffer(s) may also be empty (containing NULL),

In what scenario it will be null?

@lubosdz
Copy link
Contributor Author

lubosdz commented Aug 8, 2023

@rob006 I really don't know. I was testing older Yii.1 online app on PHP 8.2.3 to see how costy it would to to upgrade. Out of all traced issues there was the only one caused by framework (Yii 1.1.28) - on line 414 (method CClientScript::renderHead()). Casting to string fixed the issue. Then I noted same preg_match() expressions in renderBodyBegin() and renderBodyEnd() and added to PR to potentially fix those too. I am not going to investigate details why was buffer NULL on line 414, no time for that. Feel free to close this PR if you think it's not justified or wait till someone confirms.

@rob006
Copy link
Contributor

rob006 commented Aug 8, 2023

These methods do not accept nulls according to phpdoc, so if we want to handle nulls here, we should update phpdoc too. But IMO it would be better to identify case when this is happening and ensure that output is string before we pass it to methods for output processing.

@lubosdz
Copy link
Contributor Author

lubosdz commented Aug 9, 2023

These methods do not accept nulls according to phpdoc.

Well, they are public methods with pointer argument :-) So technically anything can be passed in whatever the documentation says. CClientScript may also be extended and the method(s) modified. I agree it would be better to provide particular details how NULL was passed in, so if I have some time on hands I may look into that.

@marcovtwout
Copy link
Member

Closing the PR as the issue seems to be in user code, otherwise feel free to reopen.

@marcovtwout marcovtwout closed this Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants